package com.uchedao.seller.widget.dialog;

import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.uchedao.seller.R;
import com.uchedao.seller.http.entity.CarBiddingBean;
import com.uchedao.seller.ui.car.publish.PublishBidRuleActivity;
import com.uchedao.seller.util.Arith;

/**
 * 降价再拍弹窗
 * Created by hang on 2015/10/28.
 */
public class CutPriceDialog extends CommonDialog implements View.OnClickListener {

    private CarBiddingBean bean;

    public CutPriceDialog(Context context) {
        super(context, R.layout.dlg_cut_price, 300, ActionBar.LayoutParams.WRAP_CONTENT);
    }

    @Override
    public void initDlgView() {
        setImageByURL(R.id.ivCutPricePic, bean.getCover_photo());
        setText(R.id.tvCutPriceTitle, bean.getTitle());
        setText(R.id.tvCutPriceReservePrice, Arith.div(bean.getReserve_price(), 10000)+"万元");
        setText(R.id.tvCutPriceKmDate, Arith.div(bean.getKilometer(), 10000)+"万公里 "+bean.getCard_time());
        setText(R.id.tvCutPriceMaxPrice, "¥ 最高出价"+Arith.div(bean.getMax_bid_price(), 10000)+"万元");

        getView(R.id.btnCutPriceCancel).setOnClickListener(this);
        getView(R.id.btnCutPriceOK).setOnClickListener(this);
    }

    public void setCarBiddingBean(CarBiddingBean bean) {
        this.bean = bean;
    }

    @Override
    public void onClick(View view) {
        switch(view.getId()) {
            case R.id.btnCutPriceCancel:
                dismiss();
                break;

            case R.id.btnCutPriceOK:
                Intent it = new Intent(context, PublishBidRuleActivity.class);
                it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                it.putExtra("carId", bean.getId());
                it.putExtra("price", bean.getReserve_price());
                context.startActivity(it);
                dismiss();
                break;
        }
    }
}
